<?php
get_header();
$active_option = get_option('azio_style_option', 'option_not_set');
$oCategory = get_queried_object();
//$object_posts = new Azio_Posts();
?>   

<div id="main-container" class="<?php echo $active_option->main_container; ?>">
    <div class="page-top-leader omega<?php echo ' '.$active_option->page_top_leader; ?>">
        <div class="container_12 relatived clearfix">
            <h1 class="page-title">Sản Phẩm</h1>
            <?php
            if (function_exists('yoast_breadcrumb')) {
                yoast_breadcrumb('<div class="breadcrumb">', '</div>');
            }
            ?>
        </div>
    </div>
    <!-- .page-top-leader -->
    <div class="container_12">
        <?php get_sidebar('product'); ?>
        <!-- end #column-left -->
        <div class="aside-container grid_9 omega">

            <div class="category-box">
                <div class="category-desc">
                    <p>Sản phẩm nội thất</p>
                </div>
            </div>

            <div class="product-grid grid_9 omega">
                <?php
                $i = 1;
                while (have_posts()): the_post();
                    ?>
                    <?php
                    $permalink = get_permalink();
                    $product_fields = Azio_Posts::getProductField(get_the_ID(), true);
                    $image_featured = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'featured-image');
                    ?>
                    <div class="product-box grid_3 <?php if ($i % 3 == 0) echo 'omega'; ?>">
                        <a class="img-cover" href="<?php echo $permalink ?>"> <img src="<?php echo $image_featured[0] ?>" alt="<?php echo esc_attr(get_the_title()); ?>"> </a>

                        <div class="product-meta">
                            <div class="title"><a href="<?php echo $permalink ?>"><?php the_title() ?></a></div>
                            <div class="price">
                                <?php if ($product_fields['giathitruong']): ?><span class="old-price"><?php echo number_format($product_fields['giathitruong'], 0, ',', ','); ?> ₫</span><?php endif; ?>
                                <?php if ($product_fields['giaban']): ?><span class="new-price"><?php echo number_format($product_fields['giaban'], 0, ',', ','); ?> ₫</span><?php endif; ?>
                            </div>
                        </div>
                        <!-- product-meta -->

                        <ul class="product-action">
                            <li>
                                <div class="tooltip-wrapper"><span class="tooltip">Xem chi tiết</span></div>
                                <a href="<?php echo $permalink ?>" class="icomoon" aria-hidden="true" data-icon="&#xe01c;"></a>
                            </li>
                            <li>
                                <div class="tooltip-wrapper"><span class="tooltip">Thêm vào giỏ</span></div>
                                <a href="javascript:void(0);" onClick="javascript:addOneToCart(this, <?php the_ID() ?>);" class="icomoon" aria-hidden="true" data-icon="&#x25e0;"></a></li>
                        </ul>
                    </div>
                    <!-- .product-box -->
                    <?php
                    $i++;
                endwhile;
                ?> 


            </div>
            <!-- product-grid -->
            <div class="grid_9 center-text omega">
                <?php if (function_exists('wp_pagenavi')) wp_pagenavi(); ?>
                <!-- / Paging-->
            </div>
        </div>
        <!-- end .aside-container --> 
    </div>
    <!-- end .container_12 -->


    <?php get_template_part('block', 'baseinfo') ?>
    <!-- end .base-info -->
</div>
<!-- end #main-container -->

<?php get_footer(); ?>